package com.fx.service.impl;

import cn.hutool.core.date.DateUtil;
import com.fx.entity.AdminTempUser;
import com.fx.entity.WxPayConfig;
import com.fx.mapper.WxPayConfigMapper;
import com.fx.service.WxPayConfigService;
import com.fx.util.IdWorker;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class WxPayConfigServiceImpl implements WxPayConfigService {
    @Autowired
    private WxPayConfigMapper wxPayConfigMapper;
    @Autowired
    private IdWorker idWorker;

    @Override
    public WxPayConfig getById(String flId) {
        return wxPayConfigMapper.getById(flId);
    }

    @Override
    public List<WxPayConfig> getList(Map<String, Object> map) {
        return wxPayConfigMapper.queryList(map);
    }

    @Override
    public int getCount(Map<String, Object> map) {
        return wxPayConfigMapper.queryCount(map);
    }

    @Override
    public int save(WxPayConfig wxPayConfig) {
        wxPayConfig.setFlId(String.valueOf(idWorker.nextId()));
        wxPayConfig.setFlCreatedTime(DateUtil.now());
        wxPayConfig.setFlCreator(((AdminTempUser) SecurityUtils.getSubject().getPrincipal()).getFlName());
        return wxPayConfigMapper.save(wxPayConfig);
    }

    @Override
    public int updateById(WxPayConfig wxPayConfig) {
        return wxPayConfigMapper.updateById(wxPayConfig);
    }

    @Override
    public int remove(String flId) {
        return wxPayConfigMapper.remove(flId);
    }

    @Override
    public int batchRemove(String[] flIds) {
        return wxPayConfigMapper.batchRemove(flIds);
    }

}
